{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f35f5227-1ded-44c4-985b-b75fe748876d",
   "metadata": {},
   "source": [
    "# Ladder\n",
    "\n",
    "**Codebase:https://github.com/microsoft/BitBLAS/tree/osdi24_ladder_artifact**\n",
    "```python\n",
    "python ladder_from_onnx.py --prefix ./llama2_70b_single_layer/model.onnx\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "5bfda684-1ca2-4999-8609-505a3c974b7e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import ladder"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fe8e1349-c2f0-4cce-a39c-9a6bd0fff338",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/root/Ladder/3rdparty/tvm/python/tvm/target/target.py:397: UserWarning: Try specifying cuda arch by adding 'arch=sm_xx' to your target.\n",
      "  warnings.warn(\"Try specifying cuda arch by adding 'arch=sm_xx' to your target.\")\n",
      "32\n",
      "Output93, \n",
      "add92, reshape91, \n",
      "nn.dense90, \n",
      "exp47, subtract46, \n",
      "divide44, Constant43, reshape42, \n",
      "reshape39, transpose38, reshape37, broadcast_to36, concatenate32, add34, strided_slice31, negative30, transpose40, expand_dims35, multiply33, strided_slice29, multiply28, \n",
      "transpose27, reshape26, reshape25, \n",
      "max45, \n",
      "reshape23, add22, multiply21, concatenate20, strided_slice19, negative18, strided_slice17, multiply16, \n",
      "nn.batch_matmul41, \n",
      "reshape14, transpose15, reshape13, \n",
      "nn.dense24, \n",
      "reshape11, multiply10, cast9, multiply8, \n",
      "divide7, sqrt6, add5, Constant4, mean3, Constant1, \n",
      "reshape83, \n",
      "nn.dense12, \n",
      "reshape89, reshape87, multiply88, multiply85, sigmoid84, \n",
      "multiply2, cast0, \n",
      "sum48, \n",
      "reshape52, cast51, cast50, divide49, \n",
      "nn.dense53, \n",
      "reshape60, reshape59, transpose61, broadcast_to58, expand_dims57, transpose56, reshape55, reshape54, \n",
      "nn.batch_matmul62, \n",
      "reshape66, transpose64, reshape65, reshape63, \n",
      "nn.dense67, \n",
      "add69, reshape68, \n",
      "multiply72, cast70, \n",
      "divide77, sqrt76, add75, Constant74, mean73, Constant71, \n",
      "multiply80, cast79, multiply78, \n",
      "reshape81, \n",
      "nn.dense82, \n",
      "nn.dense86, \n",
      "dense is not optimized for this platform.\n",
      "dense is not optimized for this platform.\n",
      "batch_matmul is not optimized for this platform.\n",
      "dense is not optimized for this platform.\n",
      "batch_matmul is not optimized for this platform.\n",
      "dense is not optimized for this platform.\n",
      "dense is not optimized for this platform.\n",
      "dense is not optimized for this platform.\n",
      "dense is not optimized for this platform.\n",
      "2024-10-24 16:45:31 [ladder:INFO]: Tuning ['cast_multiply_0', 'mean_add_sqrt_divide_1', 'multiply_cast_multiply_reshape_2']\n",
      "2024-10-24 16:45:32 [ladder:INFO]: Tuning ['cast_multiply_0', 'mean_add_sqrt_divide_1']\n",
      "2024-10-24 16:45:39 [ladder:INFO]: result: 0.003686400130391121                 \n",
      "2024-10-24 16:45:39 [ladder:INFO]: Tuning ['cast_multiply_0']                   \n",
      "2024-10-24 16:45:46 [ladder:INFO]: result: 0.0025298823602497578                \n",
      "2024-10-24 16:45:46 [ladder:INFO]: Tuning ['mean_add_sqrt_divide_1']            \n",
      "2024-10-24 16:45:49 [ladder:INFO]: result: 0.0032191998325288296                \n",
      "2024-10-24 16:45:49 [ladder:INFO]: Tuning ['cast_multiply_0', 'mean_add_sqrt_divide_1', 'multiply_cast_multiply_reshape_2']\n",
      "2024-10-24 16:45:50 [ladder:INFO]: Fusion group created: 0 ['cast_multiply_0', 'mean_add_sqrt_divide_1']\n",
      "2024-10-24 16:45:50 [ladder:INFO]: Tuning ['multiply_cast_multiply_reshape_2', 'nn_dense_3', 'nn_dense_6', 'nn_dense_15']\n",
      "2024-10-24 16:45:50 [ladder:INFO]: Tuning ['multiply_cast_multiply_reshape_2']  \n",
      "2024-10-24 16:45:54 [ladder:INFO]: result: 0.0024840000551193953                \n",
      "2024-10-24 16:45:54 [ladder:INFO]: Fusion group created: 1 ['multiply_cast_multiply_reshape_2']\n",
      "2024-10-24 16:45:54 [ladder:INFO]: Tuning ['nn_dense_3', 'reshape_reshape_transpose_4']\n",
      "2024-10-24 16:45:59 [ladder:INFO]: result: 0.15735039114952087                  \n",
      "2024-10-24 16:45:59 [ladder:INFO]: Tuning ['nn_dense_3', 'reshape_reshape_transpose_4']\n",
      "2024-10-24 16:46:03 [ladder:INFO]: result: 0.20070399343967438                  \n",
      "2024-10-24 16:46:03 [ladder:INFO]: Tuning ['nn_dense_3']                        \n",
      "2024-10-24 16:46:08 [ladder:INFO]: result: 0.1441279947757721                   \n",
      "2024-10-24 16:46:08 [ladder:INFO]: Tuning ['reshape_reshape_transpose_4']       \n",
      "2024-10-24 16:46:17 [ladder:INFO]: result: 0.00219345442019403                  \n",
      "2024-10-24 16:46:17 [ladder:INFO]: Tuning ['nn_dense_3']                        \n",
      "2024-10-24 16:46:17 [ladder:INFO]: Fusion group created: 2 ['nn_dense_3']       \n",
      "2024-10-24 16:46:17 [ladder:INFO]: Tuning ['reshape_reshape_transpose_4', 'multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_reshape_5']\n",
      "2024-10-24 16:46:17 [ladder:INFO]: Tuning ['reshape_reshape_transpose_4']       \n",
      "2024-10-24 16:46:17 [ladder:INFO]: Fusion group created: 3 ['reshape_reshape_transpose_4']\n",
      "2024-10-24 16:46:17 [ladder:INFO]: Tuning ['multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_reshape_5', 'nn_dense_6', 'reshape_reshape_transpose_7', 'multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_expand_dims_broadcast_to_reshape_transpose_reshape_transpose_8', 'nn_batch_matmul_9']\n",
      "2024-10-24 16:46:17 [ladder:INFO]: Tuning ['multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_reshape_5']\n",
      "2024-10-24 16:46:27 [ladder:INFO]: result: 0.002269866643473506                 \n",
      "2024-10-24 16:46:27 [ladder:INFO]: Fusion group created: 4 ['multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_reshape_5']\n",
      "2024-10-24 16:46:27 [ladder:INFO]: Tuning ['nn_dense_6', 'reshape_reshape_transpose_7']\n",
      "2024-10-24 16:46:32 [ladder:INFO]: result: 0.032153598964214325                 \n",
      "2024-10-24 16:46:32 [ladder:INFO]: Tuning ['nn_dense_6', 'reshape_reshape_transpose_7']\n",
      "2024-10-24 16:46:35 [ladder:INFO]: result: 0.16315732896327972                  \n",
      "2024-10-24 16:46:35 [ladder:INFO]: Tuning ['nn_dense_6']                        \n",
      "2024-10-24 16:46:40 [ladder:INFO]: result: 0.006829713936895132                 \n",
      "2024-10-24 16:46:40 [ladder:INFO]: Tuning ['reshape_reshape_transpose_7']       \n",
      "2024-10-24 16:46:46 [ladder:INFO]: result: 0.002187636448070407                 \n",
      "2024-10-24 16:46:46 [ladder:INFO]: Tuning ['nn_dense_6']                        \n",
      "2024-10-24 16:46:46 [ladder:INFO]: Fusion group created: 5 ['nn_dense_6']       \n",
      "2024-10-24 16:46:46 [ladder:INFO]: Tuning ['reshape_reshape_transpose_7', 'multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_expand_dims_broadcast_to_reshape_transpose_reshape_transpose_8']\n",
      "2024-10-24 16:46:47 [ladder:INFO]: Tuning ['reshape_reshape_transpose_7']       \n",
      "2024-10-24 16:46:47 [ladder:INFO]: Fusion group created: 6 ['reshape_reshape_transpose_7']\n",
      "2024-10-24 16:46:47 [ladder:INFO]: Tuning ['multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_expand_dims_broadcast_to_reshape_transpose_reshape_transpose_8', 'nn_batch_matmul_9']\n",
      "2024-10-24 16:46:51 [ladder:INFO]: result: 0.0027648000977933407                \n",
      "2024-10-24 16:46:51 [ladder:INFO]: Tuning ['multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_expand_dims_broadcast_to_reshape_transpose_reshape_transpose_8']\n",
      "2024-10-24 16:47:01 [ladder:INFO]: result: 0.002321066800504923                 \n",
      "2024-10-24 16:47:01 [ladder:INFO]: Tuning ['nn_batch_matmul_9']                 \n",
      "2024-10-24 16:47:05 [ladder:INFO]: result: 0.0023893334437161684                \n",
      "2024-10-24 16:47:05 [ladder:INFO]: Tuning ['multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_expand_dims_broadcast_to_reshape_transpose_reshape_transpose_8', 'nn_batch_matmul_9', 'reshape_divide_10']\n",
      "2024-10-24 16:47:10 [ladder:INFO]: result: 0.003276800038293004                 \n",
      "2024-10-24 16:47:10 [ladder:INFO]: Tuning ['reshape_divide_10']                 \n",
      "2024-10-24 16:47:14 [ladder:INFO]: result: 0.0024774738121777773                \n",
      "2024-10-24 16:47:14 [ladder:INFO]: Tuning ['multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_expand_dims_broadcast_to_reshape_transpose_reshape_transpose_8', 'nn_batch_matmul_9', 'reshape_divide_10', 'max_11', 'subtract_exp_12']\n",
      "2024-10-24 16:47:19 [ladder:INFO]: result: 0.003276800038293004                 \n",
      "2024-10-24 16:47:19 [ladder:INFO]: Tuning ['max_11']                            \n",
      "2024-10-24 16:47:23 [ladder:INFO]: result: 0.0023503999691456556                \n",
      "2024-10-24 16:47:23 [ladder:INFO]: Tuning ['subtract_exp_12']                   \n",
      "2024-10-24 16:47:27 [ladder:INFO]: result: 0.0025031110271811485                \n",
      "2024-10-24 16:47:27 [ladder:INFO]: Tuning ['multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_expand_dims_broadcast_to_reshape_transpose_reshape_transpose_8', 'nn_batch_matmul_9', 'reshape_divide_10', 'max_11', 'subtract_exp_12', 'sum_13', 'divide_cast_cast_reshape_14']\n",
      "2024-10-24 16:47:33 [ladder:INFO]: result: 0.0033279999624937773                \n",
      "2024-10-24 16:47:33 [ladder:INFO]: Tuning ['sum_13']                            \n",
      "2024-10-24 16:47:37 [ladder:INFO]: result: 0.0023713684640824795                \n",
      "2024-10-24 16:47:37 [ladder:INFO]: Tuning ['divide_cast_cast_reshape_14']       \n",
      "2024-10-24 16:47:40 [ladder:INFO]: result: 0.002368000103160739                 \n",
      "2024-10-24 16:47:40 [ladder:INFO]: Tuning ['multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_expand_dims_broadcast_to_reshape_transpose_reshape_transpose_8', 'nn_batch_matmul_9', 'reshape_divide_10', 'max_11', 'subtract_exp_12', 'sum_13', 'divide_cast_cast_reshape_14', 'nn_dense_15', 'reshape_reshape_transpose_expand_dims_broadcast_to_reshape_reshape_transpose_16', 'nn_batch_matmul_17']\n",
      "2024-10-24 16:47:41 [ladder:INFO]: Fusion group created: 7 ['multiply_strided_slice_negative_strided_slice_concatenate_multiply_add_expand_dims_broadcast_to_reshape_transpose_reshape_transpose_8', 'nn_batch_matmul_9', 'reshape_divide_10', 'max_11', 'subtract_exp_12', 'sum_13', 'divide_cast_cast_reshape_14']\n",
      "2024-10-24 16:47:41 [ladder:INFO]: Tuning ['nn_dense_15', 'reshape_reshape_transpose_expand_dims_broadcast_to_reshape_reshape_transpose_16']\n",
      "2024-10-24 16:47:44 [ladder:INFO]: result: 0.16315732896327972                  \n",
      "2024-10-24 16:47:44 [ladder:INFO]: Tuning ['nn_dense_15', 'reshape_reshape_transpose_expand_dims_broadcast_to_reshape_reshape_transpose_16']\n",
      "2024-10-24 16:47:44 [ladder:ERROR]: Failed to get base tile: Traceback (most recent call last):\n",
      "  3: TVMFuncCall\n",
      "  2: tvm::runtime::PackedFuncObj::Extractor<tvm::runtime::PackedFuncSubObj<tvm::runtime::TypedPackedFunc<tvm::runtime::Map<tvm::tir::Var, tvm::PrimExpr, void, void> (tvm::runtime::Array<tvm::arith::IterSumExpr, void> const&, tvm::runtime::Array<tvm::PrimExpr, void>)>::AssignTypedLambda<tvm::runtime::Map<tvm::tir::Var, tvm::PrimExpr, void, void> (*)(tvm::runtime::Array<tvm::arith::IterSumExpr, void> const&, tvm::runtime::Array<tvm::PrimExpr, void>)>(tvm::runtime::Map<tvm::tir::Var, tvm::PrimExpr, void, void> (*)(tvm::runtime::Array<tvm::arith::IterSumExpr, void> const&, tvm::runtime::Array<tvm::PrimExpr, void>), std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)::{lambda(tvm::runtime::TVMArgs const&, tvm::runtime::TVMRetValue*)#1}> >::Call(tvm::runtime::PackedFuncObj const*, tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)\n",
      "  1: tvm::arith::InverseAffineIterMap(tvm::runtime::Array<tvm::arith::IterSumExpr, void> const&, tvm::runtime::Array<tvm::PrimExpr, void>)\n",
      "  0: tvm::arith::InverseAffineIterMapTransformer::operator()(tvm::runtime::Array<tvm::arith::IterSumExpr, void> const&, tvm::runtime::Array<tvm::PrimExpr, void> const&)\n",
      "  File \"/root/Ladder/3rdparty/tvm/src/arith/iter_affine_map.cc\", line 2128\n",
      "TVMError: \n",
      "---------------------------------------------------------------\n",
      "An error occurred during the execution of TVM.\n",
      "For more information, please see: https://tvm.apache.org/docs/errors.html\n",
      "---------------------------------------------------------------\n",
      "  Check failed: (iter_map.size() == outputs.size()) is false: \n",
      "2024-10-24 16:47:44 [ladder:INFO]: Tuning ['nn_dense_15']                       \n",
      "2024-10-24 16:47:44 [ladder:INFO]: Tuning ['reshape_reshape_transpose_expand_dims_broadcast_to_reshape_reshape_transpose_16']\n",
      "2024-10-24 16:47:54 [ladder:INFO]: result: 0.002187636448070407                 \n",
      "2024-10-24 16:47:54 [ladder:INFO]: Tuning ['nn_dense_15']                       \n",
      "2024-10-24 16:47:54 [ladder:INFO]: Fusion group created: 8 ['nn_dense_15']      \n",
      "2024-10-24 16:47:54 [ladder:INFO]: Tuning ['reshape_reshape_transpose_expand_dims_broadcast_to_reshape_reshape_transpose_16', 'nn_batch_matmul_17']\n",
      "2024-10-24 16:48:42 [ladder:INFO]: result: 0.0023040000814944506                \n",
      "2024-10-24 16:48:42 [ladder:INFO]: Tuning ['nn_batch_matmul_17']                \n",
      "2024-10-24 16:48:50 [ladder:INFO]: result: 0.0023040000814944506                \n",
      "2024-10-24 16:48:50 [ladder:INFO]: Tuning ['reshape_reshape_transpose_expand_dims_broadcast_to_reshape_reshape_transpose_16', 'nn_batch_matmul_17', 'reshape_transpose_reshape_reshape_18']\n",
      "2024-10-24 16:48:55 [ladder:INFO]: result: 0.002500923117622733                 \n",
      "2024-10-24 16:48:55 [ladder:INFO]: Tuning ['reshape_transpose_reshape_reshape_18']\n",
      "2024-10-24 16:48:59 [ladder:INFO]: result: 0.0025599999353289604                \n",
      "2024-10-24 16:48:59 [ladder:INFO]: Tuning ['reshape_reshape_transpose_expand_dims_broadcast_to_reshape_reshape_transpose_16', 'nn_batch_matmul_17', 'reshape_transpose_reshape_reshape_18', 'nn_dense_19']\n",
      "2024-10-24 16:48:59 [ladder:INFO]: Fusion group created: 9 ['reshape_reshape_transpose_expand_dims_broadcast_to_reshape_reshape_transpose_16', 'nn_batch_matmul_17', 'reshape_transpose_reshape_reshape_18']\n",
      "2024-10-24 16:48:59 [ladder:INFO]: Tuning ['nn_dense_19', 'reshape_add_20']     \n",
      "2024-10-24 16:49:03 [ladder:INFO]: result: 0.15933439135551453                  \n",
      "2024-10-24 16:49:03 [ladder:INFO]: Tuning ['nn_dense_19', 'reshape_add_20']     \n",
      "2024-10-24 16:49:07 [ladder:INFO]: result: 0.2011733204126358                   \n",
      "2024-10-24 16:49:07 [ladder:INFO]: Tuning ['nn_dense_19']                       \n",
      "2024-10-24 16:49:07 [ladder:INFO]: Tuning ['reshape_add_20']                    \n",
      "2024-10-24 16:49:12 [ladder:INFO]: result: 0.002297600032761693                 \n",
      "2024-10-24 16:49:12 [ladder:INFO]: Tuning ['nn_dense_19']                       \n",
      "2024-10-24 16:49:12 [ladder:INFO]: Fusion group created: 10 ['nn_dense_19']     \n",
      "2024-10-24 16:49:12 [ladder:INFO]: Tuning ['reshape_add_20', 'cast_multiply_21', 'mean_add_sqrt_divide_22', 'multiply_cast_multiply_23', 'reshape_24', 'nn_dense_25', 'reshape_26', 'nn_dense_27', 'sigmoid_multiply_reshape_multiply_reshape_28', 'nn_dense_29', 'reshape_add_30']\n",
      "2024-10-24 16:49:12 [ladder:INFO]: Tuning ['reshape_add_20']                    \n",
      "2024-10-24 16:49:12 [ladder:INFO]: Fusion group created: 11 ['reshape_add_20']  \n",
      "2024-10-24 16:49:12 [ladder:INFO]: Tuning ['cast_multiply_21', 'mean_add_sqrt_divide_22', 'multiply_cast_multiply_23']\n",
      "2024-10-24 16:49:12 [ladder:INFO]: Tuning ['cast_multiply_21', 'mean_add_sqrt_divide_22']\n",
      "2024-10-24 16:49:12 [ladder:INFO]: Tuning ['cast_multiply_21']                  \n",
      "2024-10-24 16:49:12 [ladder:INFO]: Tuning ['mean_add_sqrt_divide_22']           \n",
      "2024-10-24 16:49:12 [ladder:INFO]: Tuning ['cast_multiply_21', 'mean_add_sqrt_divide_22', 'multiply_cast_multiply_23']\n",
      "2024-10-24 16:49:12 [ladder:INFO]: Fusion group created: 12 ['cast_multiply_21', 'mean_add_sqrt_divide_22']\n",
      "2024-10-24 16:49:12 [ladder:INFO]: Tuning ['multiply_cast_multiply_23', 'reshape_24']\n",
      "2024-10-24 16:49:16 [ladder:INFO]: result: 0.002236444503068924                 \n",
      "2024-10-24 16:49:16 [ladder:INFO]: Tuning ['multiply_cast_multiply_23']         \n",
      "2024-10-24 16:49:16 [ladder:INFO]: Tuning ['multiply_cast_multiply_23', 'reshape_24', 'nn_dense_25', 'nn_dense_27']\n",
      "2024-10-24 16:49:16 [ladder:INFO]: Fusion group created: 13 ['multiply_cast_multiply_23', 'reshape_24']\n",
      "2024-10-24 16:49:16 [ladder:INFO]: Tuning ['nn_dense_25', 'reshape_26']         \n",
      "2024-10-24 16:49:21 [ladder:INFO]: result: 0.4925439953804016                   \n",
      "2024-10-24 16:49:21 [ladder:INFO]: Tuning ['nn_dense_25', 'reshape_26']         \n",
      "2024-10-24 16:49:25 [ladder:INFO]: result: 0.5303786396980286                   \n",
      "2024-10-24 16:49:25 [ladder:INFO]: Tuning ['nn_dense_25']                       \n",
      "2024-10-24 16:49:25 [ladder:INFO]: Tuning ['nn_dense_25', 'reshape_26', 'nn_dense_27', 'sigmoid_multiply_reshape_multiply_reshape_28']\n",
      "2024-10-24 16:49:32 [ladder:INFO]: result: 0.9988096356391907                   \n",
      "2024-10-24 16:49:32 [ladder:INFO]: Tuning ['nn_dense_27']                       \n",
      "2024-10-24 16:49:32 [ladder:INFO]: Tuning ['sigmoid_multiply_reshape_multiply_reshape_28']\n",
      "2024-10-24 16:49:39 [ladder:INFO]: result: 0.002457600086927414                 \n",
      "2024-10-24 16:49:39 [ladder:INFO]: Fusion group created: 14 ['nn_dense_25', 'reshape_26']\n",
      "2024-10-24 16:49:39 [ladder:INFO]: Tuning ['nn_dense_27', 'sigmoid_multiply_reshape_multiply_reshape_28']\n",
      "2024-10-24 16:49:45 [ladder:INFO]: result: 0.5087040066719055                   \n",
      "2024-10-24 16:49:45 [ladder:INFO]: Tuning ['nn_dense_27', 'sigmoid_multiply_reshape_multiply_reshape_28']\n",
      "2024-10-24 16:49:49 [ladder:INFO]: result: 0.5468416213989258                   \n",
      "2024-10-24 16:49:49 [ladder:INFO]: Tuning ['nn_dense_27']                       \n",
      "2024-10-24 16:49:49 [ladder:INFO]: Fusion group created: 15 ['nn_dense_27']     \n",
      "2024-10-24 16:49:49 [ladder:INFO]: Tuning ['sigmoid_multiply_reshape_multiply_reshape_28', 'nn_dense_29']\n",
      "2024-10-24 16:49:49 [ladder:INFO]: Tuning ['sigmoid_multiply_reshape_multiply_reshape_28']\n",
      "2024-10-24 16:49:49 [ladder:INFO]: Fusion group created: 16 ['sigmoid_multiply_reshape_multiply_reshape_28']\n",
      "2024-10-24 16:49:49 [ladder:INFO]: Tuning ['nn_dense_29', 'reshape_add_30']     \n",
      "2024-10-24 16:49:55 [ladder:INFO]: result: 0.5228544473648071                   \n",
      "2024-10-24 16:49:55 [ladder:INFO]: Tuning ['nn_dense_29', 'reshape_add_30']     \n",
      "2024-10-24 16:49:58 [ladder:INFO]: result: 0.6908586621284485                   \n",
      "2024-10-24 16:49:58 [ladder:INFO]: Tuning ['nn_dense_29']                       \n",
      "2024-10-24 16:50:03 [ladder:INFO]: result: 0.4927999973297119                   \n",
      "2024-10-24 16:50:03 [ladder:INFO]: Tuning ['reshape_add_30']                    \n",
      "2024-10-24 16:50:03 [ladder:INFO]: Tuning ['nn_dense_29']                       \n",
      "2024-10-24 16:50:03 [ladder:INFO]: Fusion group created: 17 ['nn_dense_29']     \n",
      "2024-10-24 16:50:03 [ladder:INFO]: Tuning ['reshape_add_30']                    \n",
      "2024-10-24 16:50:03 [ladder:INFO]: Fusion group created: 18 ['reshape_add_30']  \n",
      "Processing: 100%|███████████████████████████████| 47/47 [04:31<00:00,  5.78s/it]\n",
      "Execution time summary:\n",
      " mean (ms)   median (ms)    max (ms)     min (ms)     std (ms)  \n",
      "   1.8222       1.8222       1.8222       1.8222       0.0000   \n",
      "               \n"
     ]
    }
   ],
   "source": [
    "!python ladder_from_onnx.py --prefix /root/Ladder/artifact/models/llama_70b/llama2_70b_layer1_seq1_bs1/model.onnx"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "61f57c6f-35fe-4401-b41e-363dd5f0ef0e",
   "metadata": {},
   "source": [
    "## Video\n",
    "\n",
    "https://1drv.ms/v/c/4c1511b24254d525/Ebn1ue4ig6pJnROQCjPOyvMBCiAvp5JGlM2AGIhgew-bGw?e=YWh4Xc"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
